home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / elk-2_0.lha / elk-2.0 / util / alloca.c next >
C/C++ Source or Header  |  1992-10-23  |  671b  |  30 lines

  1. /* Check if the system's alloca() function actually extends the stack.
  2.  * If it doesn't, it's not usable for Elk.
  3.  *
  4.  * The second value printed should be about 100 larger (or smaller,
  5.  * depending on the stack growing direction) than the first value.
  6.  *
  7.  * On some systems you may have to delete the #include, or the line
  8.  * declaring alloca(), or both.
  9.  */
  10.  
  11. extern char *alloca();
  12.  
  13. char *stkbase;
  14.  
  15. prstk(s) char *s; {
  16.     char foo;
  17.  
  18.     printf("stack %s calling alloca(100): %lu\n", s, (long)(stkbase - &foo));
  19. }
  20.     
  21. main(ac, av) char **av; {
  22.     char *foo;
  23.  
  24.     stkbase = (char *)&foo;
  25.     prstk("before");
  26.     foo = alloca(100);
  27.     prstk(" after");
  28.     return 0;
  29. }
  30.